<div class="funcbar">
<span class="add"><i class="fa fa-plus"></i> 新增</span>
<span class="edit"><i class="fa fa-pencil"></i> 编辑</span>
<span class="del"><i class="fa fa-minus"></i> 删除</span>
<span class="detail"><i class="fa fa-bars"></i> 详细</span>
<span data-toggle="collapse" data-target="#menuS"> <i class="fa fa-search-plus"></i> 查询</span>
</div>
<div id="menuS" class="searchbar panel panel-collapse collapse" role="tabpanel" aria-expanded="true">
<form class="searchform" role="form">
<div class="line" >
<div class="col-245 input-group">
<span class="input-group-addon">菜单名称</span><input type="text" class="form-control" name="name" placeholder="模糊查询">
</div>
<div class="col-245 input-group">
<span class="input-group-addon">菜单类型</span>
<select name="type" class="form-control"><option value="">全部类型</option></select>
</div>
<div class="col-245 input-group">
<span class="input-group-addon">上级菜单</span>
<input type="text" class="form-control" name="parentN" readonly placeholder="请选择" style="cursor:pointer;"><input type="hidden" name="parentId">
<span class="input-group-addon" style="cursor:pointer;"><i class="fa fa-list-ul"></i></span>
</div>
</div>
<div class="text-center" >
<input type="hidden" name="page" value="1">
<button  type="button" data-toggle="collapse" data-target="#menuS">关闭</button> 
<button  type="reset" class="button" >清空</button> 
<button  type="button" class="searchbtn" >查询</button> 
</div>
</form>
</div>
<div id="menuD" class="data-list">

<table class="table table-hover">
<thead>
<tr>
<th field="menuId"><input type="checkbox" data-target="menuId" class="selectAll"></th>
<th field="name">菜单名称</th>
<th field="parentN">上级菜单</th>
<th field="permit">菜单许可</th>
<th field="url">菜单URL</th>
<th field="component">菜单组件</th>
<th field="typeN">菜单类型</th>
<th field="icon">菜单图标</th></tr>
</thead>
<tbody>

</tbody>
</table>
</div>
<div class="pagination">
</div>
<!-- 新增模态框（Modal） -->
<div class="modal fade" id="menuI" tabindex="-1" data-backdrop="static" role="dialog" aria-labelledby="#app" aria-hidden="true">
</div>
<!-- 修改模态框（Modal） -->
<div class="modal fade" id="menuU" tabindex="-1" data-backdrop="static" role="dialog" aria-labelledby="#app" aria-hidden="true">
</div>
<!-- 详细模态框（Modal） -->
<div class="modal fade" id="Mdetial" tabindex="-1" data-backdrop="static" role="dialog" aria-labelledby="#app" aria-hidden="true">
	<div class="modal-panel">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
					&times;
				</button>
				<h4 class="modal-title" id="myModalLabel">
					菜单详细
				</h4>
			</div>
			<div class="modal-body">
				<form>
				<div class="line">
					<div class="left-48 input-group">
						<span class="input-group-addon">菜单名称</span>
						<input type="text" class="form-control" disabled name="name">
					</div>
					<div class="right-48  input-group">
						<span class="input-group-addon">上级菜单</span>
						<input type="text" class="form-control" disabled name="parentN">
						
					</div>
				</div>
				<div class="line">
					<div class="left-48 input-group">
						<span class="input-group-addon">菜单URL</span>
						<input class="form-control" disabled name="url" type="text">
					</div>
					<div class="right-48  input-group">
						<span class="input-group-addon">菜单组件</span>
						<input type="text" class="form-control" disabled name="component">
					</div>
				</div>
				<div class="line">
					<div class="left-48 input-group">
						<span class="input-group-addon">菜单图标</span>
						<input type="text" class="form-control" disabled name="icon">
					</div>
					<div class="right-48 input-group">
						<span class="input-group-addon">菜单类型</span>
						<input type="text" class="form-control" disabled name="typeN">
					</div>
				</div>
				<div class="line">
					<div class="left-48 input-group">
						<span class="input-group-addon">许可</span>
						<input class="form-control" disabled name="permit"type="text">
					</div>
					<div class="right-48 input-group">
						<span class="input-group-addon">顺序</span>
						<input type="text" class="form-control" disabled name="order_num">
					</div>
				</div>
				<div class="line">
					<div class="left-48 input-group">
						<span class="input-group-addon">创建人</span>
						<input class="form-control" disabled name="user_crate"type="text">
					</div>
					<div class="right-48 input-group">
						<span class="input-group-addon">创建时间</span>
						<input type="text" class="form-control" disabled name="gmt_create">
					</div>
				</div>
				<div class="line">
					<div class="left-48 input-group">
						<span class="input-group-addon">最近更新人</span>
						<input class="form-control" disabled name="user_modify"type="text">
					</div>
					<div class="right-48 input-group">
						<span class="input-group-addon">最近更新时间</span>
						<input type="text" class="form-control" disabled name="gmt_modified">
					</div>
				</div>
				</form>
			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-default" data-dismiss="modal">关闭
				</button>
			</div>
		</div><!-- /.modal-content -->
	</div><!-- /.modal -->
</div>
<script>
$(document).ready(function(){
	//标签页
	_ptab = $("#menuI").getParentTab();
	
	$("#menuS").on('click','input[name="parentN"],.input-group-addon:last',function(){
		m = getMenuByPermit('admin:menu:menuTree');
		if(m && m.url){
			$("#menuS input[name='parentN']").popTree(m.url,'parent=1',sigleMenuTree,function(obj){
				$("#menuS input[name='parentId']").val(obj.tid);
				$("#menuS input[name='parentN']").val(obj.tname.indexOf('>')>0? obj.tname.substring(obj.tname.lastIndexOf('>')+1):obj.tname);
			});
		}
	});

	//新增动作
	_ptab.on('click',".add",function(){
		m = getMenuByPermit('admin:menu:add');
		$("#menuI").load(m.component,'',getData(m.url,'',function(res){if(res.types){for(var i=0;i<res.types.length;i++){$("#menuI select[name='type']").append("<option value='"+res.types[i].value+"'>"+res.types[i].name+"</option>").end();}}}));
		$("#menuI").modal('show');
	});
	//修改动作
	_ptab.on('click',".edit",function(){
		 m = getMenuByPermit('admin:menu:edit');
		 x = $("#menuD input[name='menuId']:checked");
		
		if(x.length>=1 && m){
			$("#menuU").load(m.component,'',getData(m.url,'menuId='+x.val(),function(res){$("#menuU").fillDetailData(res);}));
			$("#menuU").modal('show');
		}else{
			messageBox("请先勾选要编辑的菜单记录。","操作提示");
		}
	});
	//删除动作
	_ptab.on('click',".del",function(){
		 m = getMenuByPermit('admin:menu:del');
		 x = $("#menuD input[name='menuId']:checked");
		
		if(x.length>=1 && m){
			_p = $(this).getParentTab();
			data = "t="+new Date();
			for(i=0;i<x.length;i++){
				data += "&menuId="+$(x[i]).val();
			}
			getData(m.url,data,function(res){
				if(res.code==RESP_SUCCESS){
					messageBox(res.msg,"操作提示");
					m = getMenuByPermit('admin:menu');
					getData(m.url,_p.find("div.searchbar form").serialize(),
					function(res){ _p.fillListData(res); });
				}
			});
			
		}else{
			messageBox("请先勾选要删除的菜单记录。","操作提示");
		}
	});
	//详细动作
	_ptab.on('click',".detail",function(){
		 m = getMenuByPermit('admin:menu:get');
		 x = $("#menuD input[name='menuId']:checked");
		
		if(x.length>=1 && m){
			getData(m.url,'menu_id='+x.val(),function(res){$("#Mdetial").fillDetailData(res);});
			$("#Mdetial").modal('show');
		}else{
			messageBox("请先勾选要查看详细的菜单记录。","操作提示");
		}
	});
 });
</script>